/**
 * 
 */
package com.cipe.cmrs.bean;

import com.cipe.cmrs.util.StringUtils;

/**
 * @author Incepio
 * 
 */
public class CodeDescriptionBean {
	private Integer id;
	private String code;
	private String description;
	private String usageInstructions;
	private boolean accountStatus;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getEscapedDescription() {
		return StringUtils.INSTANCE.escape(description);
	}

	public String getUsageInstructions() {
		return usageInstructions;
	}

	public void setUsageInstructions(String usageInstructions) {
		this.usageInstructions = usageInstructions;
	}

	public String getDisplayName() {
		StringBuilder builder = new StringBuilder();
		builder.append(getValue(code));
		builder.append(getValue(getEscapedDescription()));
		String result = builder.toString();
		if (result.endsWith(" - ")) {
			return result.substring(0, result.lastIndexOf('-'));
		} else {
			return result;
		}
	}

	private String getValue(String val) {
		if (org.apache.commons.lang.StringUtils.isNotBlank(val)) {
			return val + " - ";
		} else {
			return "";
		}
	}

	public boolean getAccountStatus() {
		return accountStatus;
	}

	public void setAccountStatus(boolean accountStatus) {
		this.accountStatus = accountStatus;
	}
}
